package com.example.animation0415;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class TweenActivity extends AppCompatActivity{
   private ImageView imageView;
   private Animation animation;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tweenlayout);
        imageView = findViewById(R.id.tween_img);
    }

    //透明度渐变
    public void OnAlpha(View view){
        animation = AnimationUtils.loadAnimation(TweenActivity.this,R.anim.tween_alpha);
        imageView.startAnimation(animation);
    }

    //缩放渐变
    public void OnScale(View view){
        animation = AnimationUtils.loadAnimation(TweenActivity.this,R.anim.tween_scale);
        imageView.startAnimation(animation);
    }

    //位移动画
    public void OnTranslate(View view){
        animation = AnimationUtils.loadAnimation(TweenActivity.this,R.anim.tween_translate);
        imageView.startAnimation(animation);
    }

    //旋转动画
    public void OnRotate(View view){
        animation = AnimationUtils.loadAnimation(TweenActivity.this,R.anim.tween_rotate);
        imageView.startAnimation(animation);
    }

    //组合动画
    public void OnSet(View view){
        animation = AnimationUtils.loadAnimation(TweenActivity.this,R.anim.tween_set);
        imageView.startAnimation(animation);
    }
}
